package data;

import java.io.Serializable;

public class G5Packet implements Serializable{
   // CONST
   public static final int FIND = 0;
   public static final int GET = 1;
   public static final int RESPONSE_FIND = 2;
   public static final int RESPONSE_GET = 3;
   
   private String fileName; // file Name
   private int type;        // type request
   private String checkSum; // check sum code
   private byte[] data;     // data
   private String option;   // option
   
   /**
    * Default packet
    */
   public G5Packet() {}
   
   /**
    * Constructor packet find file (Client to Server)
    * @param fileName   = file Name 
    * @param checkSum   = check sum of file
    */
   public G5Packet(String fileName, String checkSum) {
      this.fileName = fileName;
      this.type = FIND;
      this.checkSum = checkSum;
   }
   
   /**
    * Constructor packet response result from Server to Client OR get file request from Client to Server
    * @param option  = full path of file will download
    */
   public G5Packet(String option, int type) {
      this.option = option;
      this.type = type;
   }
   
   /**
    * Constructor packet for from Server to Client
    * @param fileName
    * @param data
    */
   public G5Packet(String fileName, byte[] data) {
      this.fileName = fileName;
      this.data = data;
   }
   
   
   // getter
   public String getFileName() {
      return fileName;
   }
   
   public int getType() {
      return type;
   }
   
   public String getCheckSum() {
      return checkSum;
   }
   
   public byte[] getData() {
      return data;
   }
   
   public String getOption() {
      return option;
   }
   
   // setter
   public void setFileName(String fileName) {
      this.fileName = fileName;
   }
   
   public void setType(int type) {
      this.type = type;
   }
   
   public void setCheckSum(String checkSum) {
      this.checkSum = checkSum;
   }
   
   public void setData(byte[] data) {
      this.data = data;
   }
   
   public void setOption(String option) {
      this.option = option;
   }
}
